/* Date.h
Michael Zahniser

Header file for the Date class, which represents a date.
*/

#ifndef __FINE_DATE_H__
#define __FINE_DATE_H__

#include <string>
#include <istream>
#include <ostream>

using std::string;
using std::istream;
using std::ostream;



class Date {
public:
    // Get today's date.
    static Date Today();
    
    Date(unsigned short year = 0xFFFF, unsigned char month = 0xFF, unsigned char day = 0xFF);
    Date(const string &dateString);

    Date &operator=(const Date &date);
    Date &operator=(const string &dateString);
    // Date comparison. The year, month, or day of a date may be a wildcard,
    // in which case it will match any value.
    bool operator==(const Date &date) const;
    bool operator!=(const Date &date) const;
    bool operator<(const Date &date) const;
    bool operator<=(const Date &date) const;
    bool operator>(const Date &date) const;
    bool operator>=(const Date &date) const;

    // Determine if this date "includes" the given date.
    // If this date is a single day, it "includes" everything before it.
    // Otherwise, it "includes" everything that matches its non-wild fields.
    bool Includes(const Date &date) const;
    // Determine if this date is null (00000000).
    bool IsNull() const;
    // Determine if this date represents a single day.
    bool IsSingleDay() const;

    // Get or set the date.
    int Year() const;
    void SetYear(int year);
    int Month() const;
    void SetMonth(int month);
    int Day() const;
    void SetDay(int day);

    // Formatted IO.
    friend istream &operator>>(istream &in, Date &date);
    friend ostream &operator<<(ostream &out, const Date &date);


private:
    unsigned short year;
    unsigned char month;
    unsigned char day;
};



#endif
